package com.springboot.mapper;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.springboot.model.po.UserPO;

@Mapper
public interface UserMapper {
	//返回行数代表是否注册
	@Select("select count(*) from user where userId = #{userId}")
	public int getUserById(@Param("userId")String userId);
	
	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1 ,0 ,0 ,0)")
	public int saveUser(UserPO user);
	
	@Select("select * from user where userId=#{userId} and password=#{password}")
	public UserPO getUserByIdByPass(UserPO user);
	
	@Select("select * from user where userId=#{userId}")
	public UserPO findSerect(@Param("userId")String userId);
	
	@Select("select points from user where userId=#{userId}")
	public BigDecimal getPoints(@Param("userId")String userId);
	
	@Select("select maxPoints from user where userId=#{userId}")
	public BigDecimal getMaxPoints(@Param("userId")String userId);
	
	@Select("select memLevel from user where userId=#{userId}")
	public int getMemLevel(@Param("userId")String userId);
	
	@Update("update user set points = #{points} where userId = #{userId}")
	public int updatePoints(@Param("userId")String userId ,@Param("points") BigDecimal points);
	
	@Update("update user set maxPoints = #{maxPoints} where userId = #{userId}")
	public int updateMaxPoints(@Param("userId")String userId ,@Param("maxPoints") BigDecimal maxPoints);
	
	@Update("update user set memLevel = #{memLevel} where userId=#{userId}")
	public int updateMemLevel(@Param("userId")String userId ,@Param("memLevel") int memLevel);
}
